/*
 * @Author: 一路向阳 tt_sunzhenfeng@163.com
 * @Date: 2024-05-15 17:39:43
 * @LastEditors: 一路向阳 tt_sunzhenfeng@163.com
 * @LastEditTime: 2024-05-15 19:36:26
 * @FilePath: \react_nest_demo\react_vite\src\router\index.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { lazy, Suspense } from 'react';
import { createHashRouter } from 'react-router-dom';

const Layout = lazy(() => import('@/view/Layout'));
const Login = lazy(() => import('@/view/Login'));
const Register = lazy(() => import('@/view/Register'));
const Course = lazy(() => import('@/view/Course'));

// 懒加载的模式的组件的写法，外面需要套一层 Loading 的提示加载组件
const widthLoadingComp = (comp: JSX.Element) => (
  <Suspense fallback={<div>Loading</div>}>
    { comp }
  </Suspense>
);

const router = createHashRouter([
{
    path: '/',
    element: widthLoadingComp(<Layout />),
    children: [
      {
        path: '/login',
        element: widthLoadingComp(<Login />),
      },
      {
        path: '/register',
        element: widthLoadingComp(<Register />),
      },
      {
        path: '/course',
        element: widthLoadingComp(<Course />),
      }
    ]
  },
]);


export default router;